import nunjucks from 'nunjucks';
import { satiscPath, satisc } from '../Config/setting.js';

const ausers = [
    { Name: "user1", Sex: "boy", Age: 18 },
    { Name: "user2", Sex: "girl", Age: 19 },
    { Name: "user3", Sex: "girl", Age: 20 }
];

async function getusers(ctx, next) {
    if (ctx.path === '/Users') {
        nunjucks.configure(satiscPath, {
            autoescape: true,
            noCache: true,
            watch: true
        });
        ctx.body = nunjucks.render(satisc, { ausers });
    } else {
        ctx.status = 404;
        ctx.body = 'Page not found';
    }
    await next();
}


export const obj = [
    {
        method: "get",
        url: "/Users",
        function: getusers
    }]